
/**
 * This class has method to validate input from user
 * @author LeDangHoa
 */
package csc.training.wpsj.validate;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class InputValidation {

	public boolean checkEmpty(String input)
	{
		return input.trim().length()==0;
	}
	public boolean checkEmailFormat(String email)
	{
		
		String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
								+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
		Pattern pattern;
		Matcher matcher;
		pattern = Pattern.compile(EMAIL_PATTERN);
		matcher = pattern.matcher(email);
		return matcher.matches();
	}
	
	public boolean comparePassword(String password,String confirmPassword)
	{
		return password.equals(confirmPassword);
	}
	
	public boolean checkCellphone(String cellPhone)
	{
		boolean status= true;
		try {
			Integer.parseInt(cellPhone);
		} catch (NumberFormatException e) {
			status = false;
		}
		return status;
	}
}
